home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Files
/
Directories
/
CatInfo.h
< prev
next >
Wrap
Text File
|
2000-06-23
|
9KB
|
217 lines
// CatInfo.h
#ifndef CatInfo_h
#define CatInfo_h
#ifndef FileLocation_h
#include "FileLocation.h"
#endif
#ifndef __FINDER__
#include <Finder.h>
#endif
#ifndef AllocationBlock_h
#include "AllocationBlock.h"
#endif
class CatInfo: public CInfoPBRec
{
private:
FileLocation location;
void ThrowError( OSErr );
bool Attribute( uint8 bit ) const { return ( hFileInfo.ioFlAttrib & bit ) != 0; }
bool Flag( uint16 bit ) const { return ( hFileInfo.ioFlFndrInfo.fdFlags & bit ) != 0; }
void SetFlag( uint16 bit ) { hFileInfo.ioFlFndrInfo.fdFlags |= bit; }
void ClearFlag( uint16 bit ) { hFileInfo.ioFlFndrInfo.fdFlags &= uint16(~bit); }
public:
CatInfo();
CatInfo( const FileLocation& );
CatInfo( ::Directory );
CatInfo( ::Directory, ConstPString );
CatInfo( ::Directory, int16 index );
CatInfo( const CInfoPBRec& );
CatInfo( const CatInfo& );
void operator=( const CatInfo& );
void Get();
void Get( const FileLocation& );
void Get( ::Directory );
void Get( ::Directory, ConstPString );
void Get( ::Directory, int16 index );
// These return false on nonexistence:
bool TryToGet( ::Directory, int16 index );
bool TryToGet( const FileLocation& );
bool TryToGet();
void Set();
void Set( const FileLocation& );
bool IsRoot() const { return location.IsRoot(); }
void Up();
void Down( ConstPString );
void Sideways( ConstPString );
const FileLocation& Location() const { return location; }
::Directory AsDirectory() const;
bool Locked() const { return Attribute( 0x01 ); }
bool IsDirectory() const { return Attribute( 0x10 ); }
bool IsFile() const { return !Attribute( 0x10 ); }
bool Invisible() const { return Flag( fInvisible ); }
bool NameLocked() const { return Flag( kNameLocked ); }
bool HasCustomIcon() const { return Flag( kHasCustomIcon ); }
bool SeenByFinder() const { return Flag( kHasBeenInited ); }
void BeInvisible() { SetFlag( fInvisible ); }
void LockName() { SetFlag( kNameLocked ); }
void HaveCustomIcon() { SetFlag( kHasCustomIcon ); }
void BeSeenByFinder() { SetFlag( kHasBeenInited ); }
void BeVisible() { ClearFlag( fInvisible ); }
void UnlockName() { ClearFlag( kNameLocked ); }
void HaveNoCustomIcon() { ClearFlag( kHasCustomIcon ); }
void BeUnseenByFinder() { ClearFlag( kHasBeenInited ); }
uint8 Label() const { return uint8( ( hFileInfo.ioFlFndrInfo.fdFlags & kColor ) >> 1 ); }
void SetLabel( uint8 );
Point LocationInWindow() const { return hFileInfo.ioFlFndrInfo.fdLocation; }
void SetLocationInWindow( Point p ) { hFileInfo.ioFlFndrInfo.fdLocation = p; }
uint32 CreationTime() const { return hFileInfo.ioFlCrDat; }
uint32 ModificationTime() const { return hFileInfo.ioFlMdDat; }
uint32 BackupTime() const { return hFileInfo.ioFlBkDat; }
void SetCreationTime( uint32 t ) { hFileInfo.ioFlCrDat = t; }
void SetModificationTime( uint32 t ) { hFileInfo.ioFlMdDat = t; }
void SetBackupTime( uint32 t ) { hFileInfo.ioFlBkDat = t; }
bool HasScript() const { return (hFileInfo.ioFlXFndrInfo.fdScript & 0x80) != 0; }
ScriptID Script() const { return ScriptID( int16( hFileInfo.ioFlXFndrInfo.fdScript & 0x7f ) ); }
void HaveNoScript() { hFileInfo.ioFlXFndrInfo.fdScript = 0; }
void HaveScript( ScriptID s ) { hFileInfo.ioFlXFndrInfo.fdScript = int8(s.ID() | 0x80); }
DirectoryID PutAwayPlace() const { return DirectoryID( hFileInfo.ioFlXFndrInfo.fdPutAway ); }
void SetPutAwayPlace( DirectoryID id ) { hFileInfo.ioFlXFndrInfo.fdPutAway = id.Number(); }
class DirectoryCatInfo: public DirInfo
{
private:
bool Attribute( uint8 bit ) const { return ( ioFlAttrib & bit ) != 0; }
bool Access( uint8 bit ) const { return ( ioACUser & bit ) != 0; }
public:
bool Shared() const { return Attribute( 0x04 ); }
bool IsMountedSharePoint() const { return Attribute( 0x08 ); }
bool IsSharePoint() const { return Attribute( 0x20 ); }
bool CantSeeFolders() const { return Access( 0x01 ); }
bool CantSeeFiles() const { return Access( 0x02 ); }
bool CantMakeChanges() const { return Access( 0x04 ); }
bool NotOwner() const { return Access( 0x80 ); }
DirectoryID ID() const { return DirectoryID( ioDrDirID ); }
uint16 FileCount() const { return ioDrNmFls; }
};
class FileCatInfo: public HFileInfo
{
private:
bool Attribute( uint8 bit ) const { return ( ioFlAttrib & bit ) != 0; }
bool Flag( uint16 bit ) const { return ( ioFlFndrInfo.fdFlags & bit ) != 0; }
void SetFlag( uint16 bit ) { ioFlFndrInfo.fdFlags |= bit; }
void ClearFlag( uint16 bit ) { ioFlFndrInfo.fdFlags &= uint16(~bit); }
public:
int16 ReferenceNumber() const { return ioFRefNum; }
bool IsOpen() const { return Attribute( 0x80 ); }
bool CopyProtected() const { return Attribute( 0x40 ); }
FileType Type() const { return FileType( ioFlFndrInfo.fdType ); }
FileSignature Signature() const { return FileSignature( ioFlFndrInfo.fdCreator ); }
void SetType( FileType t ) { ioFlFndrInfo.fdType = t.Type(); }
void SetSignature( FileSignature s ) { ioFlFndrInfo.fdCreator = s.Signature(); }
bool IsAlias() const { return Flag( kIsAlias ); }
bool HasBundle() const { return Flag( fHasBundle ); }
bool IsStationery() const { return Flag( kIsStationery ); }
bool HasNoInits() const { return Flag( 0x80 ); }
bool IsSharableApplication() const { return Flag( kIsShared ); }
void BeAlias() { SetFlag( kIsAlias ); }
void HaveBundle() { SetFlag( fHasBundle ); }
void BeStationery() { SetFlag( kIsStationery ); }
void HaveNoInits() { SetFlag( 0x80 ); }
void BeSharableApplication() { SetFlag( kIsShared ); }
void BeNotAlias() { ClearFlag( kIsAlias ); }
void HaveNoBundle() { ClearFlag( fHasBundle ); }
void BeNotStationery() { ClearFlag( kIsStationery ); }
void HaveInits() { ClearFlag( 0x80 ); }
void BeNotSharableApplication() { ClearFlag( kIsShared ); }
FileID ID() const { return FileID( ioDirID ); }
uint32 ClumpSize() const { return uint32(ioFlClpSiz); }
class DataForkInfo: public HFileInfo
{
private:
bool Attribute( uint8 bit ) const { return ( ioFlAttrib & bit ) != 0; }
public:
uint32 LogicalLength() const { return uint32(ioFlLgLen); }
uint32 PhysicalLength() const { return uint32(ioFlPyLen); }
AllocationBlock FirstAllocationBlock() const { return AllocationBlock( ioFlStBlk ); }
bool IsOpen() const { return Attribute( 0x08 ); }
bool Exists() const { return ioFlStBlk != 0; }
};
class ResourceForkInfo: public HFileInfo
{
private:
bool Attribute( uint8 bit ) const { return ( ioFlAttrib & bit ) != 0; }
public:
uint32 LogicalLength() const { return uint32(ioFlRLgLen); }
uint32 PhysicalLength() const { return uint32(ioFlRPyLen); }
AllocationBlock FirstAllocationBlock() const { return AllocationBlock( ioFlRStBlk ); }
bool IsOpen() const { return Attribute( 0x04 ); }
bool Exists() const { return ioFlRStBlk != 0; }
};
DataForkInfo& Data() { return static_cast< DataForkInfo& >( static_cast< HFileInfo &>( *this ) ); }
const DataForkInfo& Data() const { return static_cast< const DataForkInfo& >( static_cast< const HFileInfo& >( *this ) ); }
ResourceForkInfo& Resources() { return static_cast< ResourceForkInfo& >( static_cast< HFileInfo& >( *this ) ); }
const ResourceForkInfo& Resources() const { return static_cast< const ResourceForkInfo& >( static_cast< const HFileInfo& >( *this ) ); }
};
DirectoryCatInfo& Directory() { Assert( IsDirectory() ); return static_cast< DirectoryCatInfo& >( dirInfo ); }
const DirectoryCatInfo& Directory() const { Assert( IsDirectory() ); return static_cast< const DirectoryCatInfo& >( dirInfo ); }
FileCatInfo& File() { Assert( !IsDirectory() ); return static_cast< FileCatInfo& >( hFileInfo ); }
const FileCatInfo& File() const { Assert( !IsDirectory() ); return static_cast< const FileCatInfo& >( hFileInfo ); }
};
#endif